
//
//  ECUIView_CDetailFooter.m
//  Edu_iOS2018
//
//  Created by yanyan on 2018/1/19.
//  Copyright © 2018年 yanyan. All rights reserved.
//
extern CGFloat TABBAR_FOOTER_HEIGHT;

#import "ECUIView_CDetailFooter.h"
@interface ECUIView_CDetailFooter()
//@property(nonatomic,strong)UILabel *promotionPriceLabel;//促销价格
//@property(nonatomic,strong)UILabel *originPriceLabel;//原价
//@property (nonatomic,strong)UIButton *studyBtn;//学习按钮，学习，购买统一
@end
@implementation ECUIView_CDetailFooter
@synthesize promotionPriceLabel = _promotionPriceLabel;
@synthesize originPriceLabel = _originPriceLabel;
@synthesize studyBtn = _studyBtn;
- (void)addSubviews
{
    [super addSubviews];
    _promotionPriceLabel = [[UILabel alloc]init];
    _promotionPriceLabel.font = [UIFont systemFontOfSize:20];
    _promotionPriceLabel.textAlignment = NSTextAlignmentCenter;
    
    _promotionPriceLabel.textColor = [UIColor colorWithHexString:@"#ef4023"];
    [self addSubview:_promotionPriceLabel];
    _originPriceLabel = [[UILabel alloc]init];
    _originPriceLabel.textColor = [UIColor colorWithHexString:@"#bfbfbf"];
    _originPriceLabel.font = [UIFont systemFontOfSize:13 * kPercentage];
    _originPriceLabel.textAlignment = NSTextAlignmentCenter;
    
    [self addSubview:_originPriceLabel];
    _studyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_studyBtn setBackgroundImage:[UIImage imageNamed:@"detail_studybg"] forState:UIControlStateNormal];
    [_studyBtn setTitle:@"立即学习" forState:UIControlStateNormal];
    [_studyBtn addTarget:self action:@selector(action_study:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_studyBtn];
    UIView *view0 = [[UIView alloc]init];
    [self addSubview:view0];
    UIView *view1 = [[UIView alloc]init];
    [self addSubview:view1];
    UIView *view2 = [[UIView alloc]init];
    [self addSubview:view2];
    
    [view0 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self);
        make.top.bottom.height.equalTo(self);
        
    }];
    [_promotionPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view0.mas_right);
        make.top.equalTo(self);
        make.bottom.mas_equalTo(self);
        
    }];
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_promotionPriceLabel.mas_right);
        make.top.bottom.height.width.equalTo(view0);
    }];
    [_originPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view1.mas_right);
        make.centerY.equalTo(_promotionPriceLabel);
    }];
    [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_originPriceLabel.mas_right);
        make.top.bottom.height.width.equalTo(view0);
    }];
    [_studyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view2.mas_right);
        make.top.equalTo(self);
        make.width.equalTo(_studyBtn.mas_height).multipliedBy(4.402);
        make.height.equalTo(@(TABBAR_FOOTER_HEIGHT));
        make.right.equalTo(self.mas_right);
    }];

}
- (void)action_study:(id)sender{
    if (self.block_selected) {
        self.block_selected(sender);
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
